package nsoft.swing.window;

import nsoft.util.UiModel;

public class ApplicationController {

	private UiManager uiManager;
	private Session session;

	public void openScreen() {
	}
	public void openScreen(UiModel model) {
		uiManager.openWindow(model.getViewModelId(), model);
	}

	public void startApplication() {
		if (session != null) {
			uiManager.openApplication(session.getSessionContext()
					.getApplicationTitle());
		}
	}

	public void closeApplication() {
		uiManager.close();
		session = null;
	}

	public void setUiType(UiType type) {
		switch (type) {
		case UI_TYPE_WEB:
			uiManager = new WebUiManager();
			break;
		case UI_TYPE_DIALOG_BASE:
			uiManager = new DialogBaseUiManager();
			break;
		case UI_TYPE_DESKTOP:
			uiManager = new DesktopUiManager();
			break;
		case UI_TYPE_MULTI_TAB:
			uiManager = new MultiTabUiManager();
			break;

		default:
			break;
		}
		uiManager.init();
	}

	// /////////////////////////////*********//////////////////////

	public UiType getUiType() {
		return uiManager.getUiType();
	}

	public MenuContext getMenuContext() {
		if (uiManager != null) {
			return uiManager.getMenuContext();
		}
		return null;
	}

	public void setMenuContext(MenuContext menuContext) {
		if (uiManager != null) {
			menuContext.setApplicationController(this);
			uiManager.setMenuContext(menuContext);
		}
	}

	public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}
/**************************************/
	public void refreshView() {

	}

	public void refreshModel() {

	}
	public void refreshModel(String... property) {

	}
}
